package com.latefly.skewwork.ui.page.practice

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.latefly.skewwork.R

@Composable
fun IconListItem(data: IconListItemData, modifier: Modifier = Modifier) {

    Row {
        Image(
            painter = painterResource(
                id = R.drawable.ic_launcher_background
            ),
            contentDescription = null,
            modifier = Modifier
                .clip(CircleShape)
                .size(40.dp)
        )
        Spacer(modifier = Modifier.width(20.dp))

        var isExpanded by remember {
            mutableStateOf(false)
        }
        Column(modifier = Modifier.clickable {
            isExpanded = !isExpanded;
        }) {
            Text(
                text = data.author,
                modifier = Modifier
                    .size(20.dp),
            )
            Text(
                text = data.tips,
                color = MaterialTheme.colorScheme.secondaryContainer,
                maxLines = if (isExpanded) 10000 else 1
            )
        }

    }
}


data class IconListItemData(val author: String, val tips: String)
